<template>
    <van-card  v-for="item in teamlist" :key="item.id"
    :price="item.product.buy"
        :thumb="item.product.thumbs_text">
        <template #title>
            <h3>{{ item.product.name }}</h3>
            <div>
                人数： <span style="color: red;">{{ item.total }}</span>人
            </div>
            <div> 拼团时间：{{ item.createtime_text }} (开始) ~ {{ item.endtime_text }} (结束)</div>
        </template>
        <template #footer>
            <van-button type="danger" size="small" @click="toPages(item.proid)">参与拼团</van-button>
            <van-button type="warning" size="small" @click="toInfoPages(item.id)">拼团详情</van-button>
        </template>
    </van-card>

    <Footer />
</template>
<script setup>
import Footer from '@/components/common/footer.vue'
const { proxy } = getCurrentInstance()
const teamlist = ref([])
onBeforeMount(() => {
    getTeamData()
})
const getTeamData = async() =>{
    let result = await Api.teamIndex()
    if(result.code == 1)
    {
        teamlist.value = result.data
    }
}
const toPages = (id) =>{
    proxy.$router.push({
        path: '/product/info',
        query: {
            proid: id
        }
    })
}

const toInfoPages = (id) =>{
    proxy.$router.push({
        path: '/team/info',
        query: {
            teamid: id
        }
    })
}
</script>